# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php82-pecl-oauth
_extname=oauth
pkgver=2.0.8
pkgrel=0
pkgdesc="PHP 8.2 extension, OAuth is an authorization protocol built on top of HTTP - PECL"
url="https://pecl.php.net/package/oauth"
arch="all"
license="BSD-3-Clause"
_phpv=82
_php=php$_phpv
depends="$_php-common"
makedepends="$_php-dev curl-dev"
checkdepends="$_php-openssl $_php-pcntl $_php-posix"
#source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz
source="php-$_extname-$pkgver.tgz::https://github.com/php/pecl-web_services-oauth/archive/refs/tags/$pkgver.tar.gz
	fix-php-8-2.patch::https://github.com/php/pecl-web_services-oauth/commit/36a08239bf62c6fbc39ce38cf95ed42e098c022d.patch
	fix-tests.patch
	"
builddir="$srcdir/pecl-web_services-$_extname-$pkgver"

build() {
	phpize$_phpv
	./configure --prefix=/usr --with-php-config=php-config$_phpv
	make
}

check() {
	local _modules="/usr/lib/$_php/modules"
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/openssl.so \
		-d extension=$_modules/pcntl.so \
		-d extension=$_modules/posix.so \
		-d extension=modules/$_extname.so" TESTS=--show-diff
	$_php -dextension=modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/60_$_extname.ini
}

sha512sums="
93ca722f70760db95c53fcf19cbc3175920785186c89bd50a7d30e952d5cc9dc4ce6758324b770a60a759a748cf44c3c9caae52e629e6f5578b4c2c1a07ee950  php-oauth-2.0.8.tgz
db69d0e8a2e5471c5d38aec8050796913c363908d21a00d373348e88990683e63d90bdc2a0150733d7c568e077f52922f65ff62a2099d9f2285388d441494b47  fix-php-8-2.patch
8944170fbc9e2e42a76fe9444e94cf28485ef3c2bac5e755a66eca93531f0c526acc23a30dcb5a273a598ccb377ce367cb6b673948c46f1e0e2478e71ebc5e38  fix-tests.patch
"
